var zona;
var zonas = {
		init:function(){
			zona = this;
			$('#zonas').jqGrid({
	           url:'zonas/index',
	           datatype:'json',
	           mtype:'POST',
	           colNames:['id','codigo','Descripcion','Creado','Estado'],
	           colModel:[
	               {name:"data[Zona][id]",hidden:true},
	               {name:"data[Zona][codigo]",align:"right",index:'Zona.codigo',width:50,align:'left',sortable:true,editoptions:{maxlength:5},editable:true,editrules:{required:true},searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
				   {name:"data[Zona][descripcion]",index:'Zona.descripcion',width:250,align:'left',sortable:true,editoptions:{maxlength:250, size:30},editable:true,editrules:{required:true},searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	               {name:"data[Zona][created]",index:'Zona.created',width:60,align:'left',sortable:true,editable:false,searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	               {name:"data[Zona][estado_id]",
				   		index:'Estado.descripcion',
						width:60,
						align:'left',
						editable: true,
						edittype:"select",
						editrules:{required:true},
						editoptions:{
							value:"1:Activo;2:Desactivo"
						},
						searchoptions:{
							sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']
						}
					}               
	           ],
		
			   pager:$('#zonas-pager'),
	           rowNum:10,
	           rowList:[10,20,30],
	           mtype: "POST",
	           viewrecords:true,
	           caption:'Zonas',
	           height:'180',
			   //width
	           sortname: "Zona.descripcion",
	           editurl: 'zonas/index'
	          
	                
	       });
	       $('#zonas').navGrid("#zonas-pager",{edit:true,add:true,del:true},
		   	{clearAfterEdit:false,reloadAfterSubmit:true, closeOnEscape:true, afterSubmit:zona.afterSubmit},
			{clearAfterAdd:true,reloadAfterSubmit:true, closeOnEscape:true,afterSubmit:zona.afterSubmit},
			{width:270,reloadAfterSubmit:true, closeOnEscape:true},
			{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew'],multipleSearch:true, closeOnEscape:true});
	       
		   $("#zonas").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
	       jQuery("#zonas").jqGrid('setGridWidth',$('#RightPane').width()-50);
		},
		afterSubmit: function(response){var respuesta = JSON.parse(response.responseText);return [respuesta.respuesta,respuesta.mensaje];}
};